package com.cytech.cloudclinic.moudle.main.expert;

import com.cytech.cloudclinic.base.BaseBean;
import com.cytech.cloudclinic.base.BaseObserver;
import com.cytech.cloudclinic.base.BasePresenter;
import com.cytech.cloudclinic.bean.Expert;
import com.cytech.cloudclinic.bean.req.GetDrug;
import com.cytech.cloudclinic.bean.resp.RespDrugList;
import com.yechaoa.yutils.ToastUtil;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.List;

import okhttp3.MediaType;
import okhttp3.RequestBody;

public class ExportPresenter extends BasePresenter<ExportView> {
    public ExportPresenter(ExportView baseView) {
        super(baseView);
    }

    /**
     * 专家列表
     */
    void getExportList(int type) {
        JSONObject json = new JSONObject();
        try {
            json.put("specialist_type",type);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        String requestStr = json.toString();
        RequestBody body = RequestBody.create(MediaType.parse("application/json; charset=utf-8"), requestStr);
        addDisposable(apiServer.getExpertList(body), new BaseObserver<BaseBean<List<Expert>>>(baseView, false) {

            @Override
            public void onSuccess(BaseBean<List<Expert>> o) {
                baseView.getExportListSuccess(o.result);
            }

            @Override
            public void onError(String msg) {
                ToastUtil.showToast(msg);
            }
        });
    }
}
